package com.flying.invest.strategy.service;

import com.flying.framework.data.Data;
import com.flying.framework.model.ActionResult;

public interface IStrategyService {
	<T extends Data> T createSub(Long strategy_id);
	ActionResult remove(Long strategy_id);
	<T extends Data> T findById(Long strategy_id);
	ActionResult executeStrategy(Long strategy_id);
	ActionResult flushDetails(Long strategy_id);
	
	class Invest {
		private Double price, amount, quantity, unit;
		public Invest(Double amount, Double price, Double unit) {
			this.price = price;
			this.amount = amount;
			this.unit = unit;
			this.calculateQuantity();
		}
		private void calculateQuantity() {
			Double q = this.amount / this.price;
			Long x = Math.round(q / unit);
			this.quantity = x * unit;
			this.amount = this.quantity * price;
		}
		public Double getAmount() {
			Double d = this.amount * 100;
			Long x = d.longValue();
			return x / 100.0;
		}
		public void setAmount(Double amount) {
			this.amount = amount;
		}
		public Double getQuantity() {
			Double d = this.quantity * 100;
			Long x = d.longValue();
			return x / 100.0;
		}
		public void setQuantity(Double q) {
			this.quantity = q;
		}
	}
}
